{% extends "master.html" %}


{% block main %}
<div class="container">
    <div class="row">
        <div class="col-md-3">
            <div class="list-group">
                <div class="list-group-item active">待办事项</div>
                {{render_todo('待审批采购单','PURCHASE_APPROVE','bpPrh.view')}}
                {{render_todo('待审批销售单','SALE_APPROVE','bpSale.view')}}
                {{render_todo('待审批调拨单','DN_APPROVE','bpTns.view')}}
                {{render_todo('待审批出入库单','INVENTORY_NOTE_APPROVE','bpIvtnt.view')}}
                {{render_todo('待审批应收账单','FIN_IN_APPROVE','bpFin.view')}}
                {{render_todo('待审批应付账单','FIN_OUT_APPROVE','bpFin.view')}}
            </div>
        </div>
        <div class="col-md-9">            
            <div class="row">
                    {% if canSale and getAllPermission(['SALE_VIEW',])%}                                      
                        {{render_module('零售管理',url_for('bpSale.view'),'sale.jpg')}}
                    {% endif %}
                    {% if canPurchase and getAllPermission(['PURCHASE_VIEW',])%}                        
                        {{render_module('采购管理',url_for('bpPrh.view'),'prh.jpg')}}
                    {% endif %}
                    {% if getAllPermission(['DN_VIEW',])%}                        
                        {{render_module('调拨管理',url_for('bpTns.view'),'tns.jpg')}}
                    {% endif %}
                    {% if getAllPermission(['INVENTORY_NOTE_VIEW',])%}                          
                        {{render_module('出入库管理',url_for('bpIvtnt.view'),'ivtnt.jpg')}}
                    {% endif %}
                    {% if getAllPermission(['INVENTORY_VIEW',])%}                        
                         {{render_module('仓位管理',url_for('bpIvt.view'),'ivt.jpg')}}
                    {% endif %}
                    <!--
                     {% if getAllPermission(['RGN_VIEW',])%}

                         {{render_module('退货管理',url_for('bpRg.view'),'aa')}}
                    {% endif %}
                    --> 
                    {% if getAllPermission(['MEMBER_VIEW',])%}                        
                        {{render_module('会员管理',url_for('bpMem.view'),'mem.jpg')}}
                    {% endif %} 
                    {% if getAllPermission(['FIN_IN_VIEW','FIN_OUT_VIEW'])%}                        
                        {{render_module('财务管理',url_for('bpFin.view'),'fin.jpg')}}
                    {% endif %}
                                       
                        {{render_module('单个商品追踪',url_for('bpTrc.view'),'trc.jpg')}}
            </div>
            
        </div> 
    </div>
</div>
{% endblock %}



{% macro render_todo(label,key,view) %}
    {% if getAllPermission([key,])%}
        <div class="list-group-item">
            <span class="badge">{{todo[key].count() }}</span>{{label}}
            <ul class="list-unstyled">
                {% for a in todo[key][:5] %}
                    <li><a href="{{url_for(view,action='view',id=a.id)}}"><i class="glyphicon glyphicon-arrow-right"></i>{{a}}</a></li>
                {% endfor %}
            </ul>
        </div>
    {% endif %}
{% endmacro %}


{% macro render_module(label,url,img) %}
    <div class="col-md-4" style="padding-bottom: 20px">
        <div class="thumbnail">
          <a href="{{url}}"><img alt="{{label}}" src="{{url_for('static', filename='img/system/%s' %img)}}"></a>
          <div class="caption">
            <h3>{{label}}</h3>
            <p class="text-right"><a href="{{url}}" class="btn btn-primary">{{BTN_ENTER}}</a></p>
          </div>
        </div>
    </div>
{% endmacro %}